<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //    编写一个函数 createTree，从嵌套对象创建一个嵌套的ul/li列表。
        let data = {
            "Fish": {
                "trout": {},
                "salmon": {}
            },
            "Tree": {
                "Huge": {
                    "sequoia": {},
                    "oak": {}
                },
                "Flowering": {
                    "apple tree": {},
                    "magnolia": {}
                }
            }
        };
        let container = document.body
        function createTree(container, data) {
            let ul = document.createElement("ul")
            for (const key in data) {
                if (key != null) {
                    let li = document.createElement('li')
                    li.innerHTML = key
                    container.append(ul)
                    ul.append(li)
                    createTree(ul, data[key])
                }
            }
            console.log(ul);
        }

        createTree(container, data);
    </script>
</body>

</html>